import {TBizcEneryEquipApi} from '@/api/equip/tBizcEneryEquipApi.js'
import moment from "moment";

export const FormEvent = {
  form: {
    id: "",//主键
    gdmc: "",//任务名称
    xqdwbm: '',
    xqdwmc: '',
    xqbzbm: '',
    xqbzmc: '',
    jhkssj: '',
    jhjssj: '',
    xqnr: '',
    xqzdType: '',
    xqzdTypeName: '',
    ssjfmc: '',
    sskfmc: '',
    createPersonName: '',
    createTime: '',
    pdPerson: '',
    pdPersonName: "",//派单人
    pdrTel: "",//派单人电话
    pdrTime: "",//派单时间
  },
  rules: {
    xqbzbm: [{required: true, message: '请选择消缺班组',}]
  },
  type: '', ////insert-update//
  initFormData(formData) { 		//初始化表单信�?//
    FormEvent.type = formData.type;
    if (FormEvent.type == 'insert') {
      for (let key in FormEvent.form) {
        FormEvent.form[key] = undefined;
      }
    } else {
      for (let key in FormEvent.form) {
        FormEvent.form[key] = formData.data[key];
      }
      this.FormEvent.form.sendTime = moment().format('YYYY-MM-DD HH:mm:ss')
    }
  },
  saveFormData() {
    if (FormEvent.type == 'insert') {
      //执行新增操作//
      const insertData = [FormEvent.form];
      return TBizcEneryEquipApi.insert(insertData);
    } else {
      //执行更新操作//
      const updateData = [FormEvent.form];
      return TBizcEneryEquipApi.update(updateData);
    }
  },

}


